package com.lk.client.loadbanlance;

import com.lk.entity.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;

/**
 * @author kun.li
 */
public class RandomRoute implements Route {
    ThreadLocalRandom current = ThreadLocalRandom.current();

    @Override
    public Service switchService(Set<Service> serviceSet) {
        int nextInt = current.nextInt(serviceSet.size());
        List<Service> list = new ArrayList<>(serviceSet);
        return list.get(nextInt);
    }
}
